package myjava.test.xml.reader.bean;

import java.util.LinkedList;
import java.util.List;

import org.dom4j.Element;

import myjava.test.xml.reader.ContextXml;

/**
 * 
 * @author zichaoyang
 *
 */
public abstract class BeanContext extends ContextXml implements BeanContextReader {

	public BeanContext(String path, boolean isRootPath) {
		super(path, isRootPath);
	}
	
	public BeanContext(String path) {
		super(path);
	}

	@Override
	public String getAttributeValue(Element element, String attribute) {
		return element.attributeValue(attribute);
	}

	@Override
	public List<String> getAttributeValue(String parentElement, String id, String value, String attribute) {
		List<Element> list = this.getSonElement(parentElement, id, value);
		List<String> strs = new LinkedList<>();
		for(Element e : list){
			strs.add(this.getAttributeValue(e, attribute));
		}
		return strs;
	}

	@Override
	public List<String> getAttributrValue(String parentElement, String value, String attribute) {
		return this.getAttributeValue(parentElement, "id", value, attribute);
	}
	
}
